//
//  UIView+Ex.m
//  WeiBo_OC
//
//  Created by MacBook Pro on 16/5/24.
//  Copyright © 2016年 MacBook Pro. All rights reserved.
//

#import "UIView+Ex.h"

@implementation UIView (Ex)


#pragma mark - 快捷访问x、y、width、height
- (void)setX:(CGFloat)x
{
    CGRect tmp = self.frame;
    tmp.origin.x = x;
    self.frame = tmp;
}

- (CGFloat)x{
    return self.frame.origin.x;
}
- (CGFloat)width{
   return self.bounds.size.width;
}

- (void)setWidth:(CGFloat )width{
    CGRect tmp = self.bounds;
    tmp.size.width = width;
    self.bounds = tmp;
}

- (CGFloat)height{
    return self.bounds.size.height;
}

- (void)setHeight:(CGFloat )height{
    CGRect tmp = self.bounds;
    tmp.size.height = height;
    self.bounds = tmp;
}

#pragma mark - 

- (void)setCornerRadius:(CGFloat)cornerRadius
{
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = YES;
}



- (void)setBorderWidth:(CGFloat)borderWidth
{
    self.layer.borderWidth = borderWidth;
}

- (void)setBorderColor:(UIColor *)borderColor
{
    self.layer.borderColor = borderColor.CGColor;
}


- (CGFloat)getScreenWidth{
    return [UIScreen mainScreen].bounds.size.width;
}

- (CGFloat)getScreenHeight{
    return [UIScreen mainScreen].bounds.size.height;
}

- (CGFloat)getScale{
    return [UIScreen mainScreen].scale;
}

@end
